package com.zff.rental.mapstruct.user;


import com.zff.rental.entity.user.UserEntity;
import com.zff.rental.mapstruct.BaseMapstruct;
import com.zff.rental.vo.user.AddUserParams;
import com.zff.rental.vo.user.LoginVo;
import com.zff.rental.vo.user.ModifyUserParams;
import com.zff.rental.vo.user.UserVo;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author HCY
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserMapstruct extends BaseMapstruct {
    UserMapstruct INSTANCE = Mappers.getMapper(UserMapstruct.class);

    @Named("toUserVo")
    UserVo map(UserEntity findResult);

    LoginVo mapToLoginVo(UserEntity findResult);

    UserEntity map(AddUserParams params);

    @Mapping(target = "userId", ignore = true)
    @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
    void merge(@MappingTarget UserEntity target, ModifyUserParams source);

    @IterableMapping(elementTargetType = UserVo.class, qualifiedByName = "toUserVo")
    List<UserVo> mapAsList(List<UserEntity> records);
}

